在現代網站中,如果每個網站都要你自己創帳號,使用者會:
流程圖:
[1] 使用者點「使用 Google 登入」
↓
[2] 被導向到 Google 的登入頁面(帶上 client_id 等參數)
↓
[3] 使用者登入 Google 並同意授權
↓
[4] Google 將「授權碼 code」傳回到你的網站(Redirect URL)
↓
[5] 你後端用這個「code + client_secret」向 Google 請求 access token
↓
[6] 拿到 access token 後,用它向 Google API 請求用戶資訊(email, name 等)
↓
[7] 拿到個資後,讓使用者在你的網站登入或註冊
OAuth 2.0 中的幾個關鍵名詞解釋: